$(function () {
    window.addEventListener(('orientationchange' in window ? 'orientationchange' : 'resize'), (function () {
        function c() {
            var d = document.documentElement;
            var cw = d.clientWidth || 640;
            // d.style.fontSize = (50 * (cw / 750)) > 40 ? 40 + 'px' : (50 * (cw / 750)) + 'px';          
            d.style.fontSize = (50 * (cw / 750)) + 'px';

        }
        c();
        return c;
    })(), false);

    $(".tj_btn").click(function () {
        var user_name = $("#user_name").val();
        if (user_name == '') {
            // ui.alert("提示", "姓名不能为空。");
            $(document).dialog({
                type: "notice",
                autoClose: 1500,
                infoText: '姓名不能为空',
            });
            return;
        }

        var telephone = $("#telephone").val();
        if (telephone == '') {
            // ui.alert("提示", "手机号不能为空。");
            $(document).dialog({
                type: "notice",
                autoClose: 1500,
                content: '手机号不能为空',
            });
            return;
        }

        if (!verifyTelephone(telephone)) {
            // ui.alert("提示", "手机号格式错误。");
            $(document).dialog({
                type: "notice",
                autoClose: 1500,
                content: '手机号格式错误',
            });
            return;
        }
        var qq = $("#qq").val();
        if (qq == '') {
            // ui.alert("提示", "qq不能为空。");
            $(document).dialog({
                type: "notice",
                autoClose: 1500,
                content: 'qq不能为空',
            });
            return;
        }
        $.ajax({
            "url": "interface.php?action=register",
            data: {
                "user_name": user_name,
                "telephone": telephone,
                "qq": qq
            },
            success: function (e) {
                if (e == "FAILURE_TELEPHONE") {
                    // ui.alert("提示", "当前用户信息已提交。");
                    $(document).dialog({
                        type: "notice",
                        autoClose: 1500,
                        content: '当前用户信息已提交。',
                    });

                } else if (e == "SUCCESS") {
                    //ui.alert("提示", "当前用户信息提交成功。");
                    $(document).dialog({
                        type: "notice",
                        autoClose: 1500,
                        content: '当前用户信息提交成功。',
                    });

                } else {
                    $(document).dialog({
                        type: "notice",
                        autoClose: 1500,
                        content: '未知错误。',
                    });

                    //ui.alert("提示", "未知错误。");
                }
            }
        });

    });
});